package cii_lib;

public class CCII_INTERFACE_JSserver implements CCII_INTERFACE{
  
  private JSserver _serv;

  public CCII_INTERFACE_JSserver(int step){
    _serv=new JSserver(step);
  }
  
  public void HardwareOpen(String ip, int port, long base, int step){
    try{
      _serv.Open(ip, port);
    }catch(JSserverException e){e.printStackTrace(); System.exit(0);}
  }

  public void HardwareClose(){
    try{
      _serv.Close();
    }catch(JSserverException e){e.printStackTrace(); System.exit(0);}
  }

  public long HardwareRead(long addr){
    try{
      return(_serv.Read(addr));
    }catch(JSserverException e){e.printStackTrace(); HardwareClose(); System.exit(0); return(0);}
  }

  public void HardwareWrite(long addr, long data) {
    
    try{
      _serv.Write(addr,data);
    }catch(JSserverException e){e.printStackTrace(); HardwareClose(); System.exit(0);}
  }

}
